import os
import sys
import glob
import threading
import  time
#单文件安装
class base_thread(threading.Thread):
    def __init__(self, func):
        threading.Thread.__init__(self)
        self.func = func
        print(type(self.func))
    def run(self):
        self.func

#单文件安装
def install(filename):
    os.popen("adb install %s" % filename)

#批量安装app,多线程安装
def bact_install(dir):
    if os.path.isdir(dir):
        starttime = time.time()
        filelist= glob.glob(dir + "*.apk")
        print(filelist)
        threads = []
        for i in range(0, len(filelist)):
            threads.append(base_thread(install(filelist[i])))
        for j in range(0, len(filelist)):
            threads[j].start()
        for k in range(0, len(filelist)):
            threads[k].join()
        print("总运行时间"+str(time.time() - starttime))
    else:
        print("目录不存在")
        sys.exit(0)

#卸载app
def uninstall(packageName):
    os.popen("adb wait-for-device")
    print("start uninstall...")
    os.popen("adb uninstall %s" % packageName)
if __name__ == '__main__':
    install("last_quickvideo.apk")